/***********************************************************************
 * Module:  QuestionImage.java
 * Author:  DAC
 * Purpose: Defines the Class QuestionImage
 ***********************************************************************/
package com.group1.model;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

/** @pdOid 7b21b81c-ffe3-4b7e-b974-fdc4789cbcfe */
public class QuestionImage {
   /** @pdOid c66d452b-4cbf-446e-8b26-e765079372e1 */
   protected void finalize() {
      // TODO: implement
   }
   
   /** @pdOid c82173a0-bf2a-45d8-a34a-4a67e057e2bd */
   public Integer questimId;
   /** @pdOid bca932f1-8f06-43d0-bf3b-23c31417ba1a */
   public java.lang.String questimLink;
   
   /** @pdRoleInfo migr=no name=Question assc=figuresOfQuestions mult=0..1 side=A */
   public Question question;
   /** @pdRoleInfo migr=no name=AnswerItem assc=picturesForAnswerItems mult=0..1 side=A */
   public AnswerItem answerItem;
   
   /** @param questImgID 
    * @param questImgLink 
    * @param questID 
    * @param answerID
    * @pdOid 196ade17-4293-428e-88c6-cce64e80844c */
   public QuestionImage(Integer questImgID, String questImgLink, Integer questID, Integer answerID) {
      // TODO: implement
   }
   
 
   /** @param session
    * @pdOid f275a157-d1f2-41b6-ad95-f6c492a2555f */
   public static List<QuestionImage> getAllQuestImg(Session session) {
      // TODO: implement
	   Query query = session.createQuery("from QuestionImage");
	   List<QuestionImage> list = query.list();
      return list;
   }
   
   /** @param questImgId 
    * @param session
    * @pdOid 215a5e72-abf0-4557-a85b-dbf5836cca98 */
   public static QuestionImage getQuestImgByID(Integer questImgId, Session session) {
      // TODO: implement
      return (QuestionImage) session.get(QuestionImage.class, questImgId);
   }
   
   
   /** @param questID 
    * @param session
    * @pdOid 7fdcf493-9b58-4522-a196-48f2d225031c */
   public static List<QuestionImage> getImgOfQuestion(Integer questID, Session session) {
      // TODO: implement
	   Query query = session.createQuery("from QuestionImage where QUESTION_ID = " + questID);
	   List<QuestionImage> list = query.list();
      return list;
   }
   
   /** @param answID 
    * @param session
    * @pdOid 72799b1b-39da-4109-ae17-eed86c826d05 */
   public static List<QuestionImage> getImgOfAnsw(Integer answID, Session session) {
      // TODO: implement
	   Query query = session.createQuery("from QuestionImage where ANSI_ID = " + answID);
	   List<QuestionImage> list = query.list();
      return list;
   }
   
   /** @pdOid 65fbc7d1-d2e7-455e-947b-36ea602f4fd5 */
   public Integer getQuestimId() {
      return questimId;
   }
   
   /** @param newQuestimId
    * @pdOid 43069605-2cd3-4964-a907-4ef4f9f04379 */
   public void setQuestimId(Integer newQuestimId) {
      questimId = newQuestimId;
   }
   
   /** @pdOid b93a4e2e-3250-4e57-8946-9dd8099db5a9 */
   public java.lang.String getQuestimLink() {
      return questimLink;
   }
   
   /** @param newQuestimLink
    * @pdOid 30c877e8-64c1-4550-98fc-02e0c366a896 */
   public void setQuestimLink(java.lang.String newQuestimLink) {
      questimLink = newQuestimLink;
   }
   
   /** @pdOid 72d12c9e-3a00-453c-906d-0249c2369ac9 */
   public QuestionImage() {
      // TODO: implement
   }
   
   
   /** @pdGenerated default parent getter */
   public Question getQuestion() {
      return question;
   }
   
   /** @pdGenerated default parent setter
     * @param newQuestion */
   public void setQuestion(Question newQuestion) {
      if (this.question == null || !this.question.equals(newQuestion))
      {
         if (this.question != null)
         {
            Question oldQuestion = this.question;
            this.question = null;
            oldQuestion.removeQuestionImage(this);
         }
         if (newQuestion != null)
         {
            this.question = newQuestion;
            this.question.addQuestionImage(this);
         }
      }
   }
   /** @pdGenerated default parent getter */
   public AnswerItem getAnswerItem() {
      return answerItem;
   }
   
   /** @pdGenerated default parent setter
     * @param newAnswerItem */
   public void setAnswerItem(AnswerItem newAnswerItem) {
      if (this.answerItem == null || !this.answerItem.equals(newAnswerItem))
      {
         if (this.answerItem != null)
         {
            AnswerItem oldAnswerItem = this.answerItem;
            this.answerItem = null;
            oldAnswerItem.removeQuestionImage(this);
         }
         if (newAnswerItem != null)
         {
            this.answerItem = newAnswerItem;
            this.answerItem.addQuestionImage(this);
         }
      }
   }

}